<?php
JunctionFileCabinet::using("Junction_Utils_Xml_Parser");
JunctionFileCabinet::using("Test_Resources_Catalog");

class Test_Junction_Utils_Xml_Parser extends UnitTestCase {
	
	private $_file;
	
	private $_badFile;
	
	public function __construct() {
		$this->_file = Test_Resources_Catalog::fetch("GoodSchema.xml");
		$this->_badFile = Test_Resources_Catalog::fetch("BadSchema.xml");
	}
	
	public function testParser() {
		$result = Junction_Utils_Xml_Parser::parseFile($this->_file);
		$classes = $result->get("class");
		$class = $classes[0];
		
		$this->assertTrue($class->tablename == "users");
		$this->assertTrue($class->classname == "Test_Mock_Client");
		$this->assertTrue(count($class->properties) == 3);
	}
	
	public function testBadParser() {
		try {
			Junction_Utils_Xml_Parser::parseFile($this->_badFile);
			$this->fail();
		} catch (Junction_Utils_Xml_Exception $e) {
			$this->pass();
		} catch (Exception $e) {
			$this->fail();
		}
	}
}
?>